
package com.kweative.model.query;


import com.kweative.model.Table;

/**
 *
 * @author henrik
 */
public class JoinPhrase extends Phrase {
    private Table table;
    private OnStatement onstmt = null;
    private JoinType type;
    public JoinPhrase(Table table, WhereStatement stmt) {
        this(table, stmt,JoinType.INNER);
    }
    public JoinPhrase(Table table, WhereStatement stmt,JoinType type) {
        super(stmt);
        this.table = table;
        this.type = type;
    }
    public OnStatement on() {
        onstmt = new OnStatement(table,(WhereStatement)getStmt());
        return onstmt;
    }

    @Override
    public String toString() {
        return " " + type.name() + " JOIN " + QueryUtil.formatTable(table) + " ON " + onstmt.compile();
    }

}
